using System;
using System.Collections.Generic;
using System.Text;

namespace Scenario_Editor.WR2TerrainLoader
{
    internal class SurfaceChunk
    {
        public uint startPolygon;
        public uint surface;
        public uint numberOfPolygons;
        public SurfaceChunk(uint startPolygon, uint surface, uint numberOfPolygons)
        {
            this.startPolygon = startPolygon;
            this.surface = surface;
            this.numberOfPolygons = numberOfPolygons;
        }

        //public override string ToString()
        //{
        //    //return startPolygon.ToString() + "\t" + surface.ToString() + "\t" + numberOfPolygons.ToString();
        //}

        internal static SurfaceChunk FromStream(System.IO.BinaryReader br)
        {
            uint startPolygon = br.ReadUInt32();
            uint surface = br.ReadUInt32();
            uint numberOfPolygons = br.ReadUInt32();
            return new SurfaceChunk(startPolygon, surface, numberOfPolygons);
        }
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(" Surface Chunk" + " ");
            sb.AppendLine(" startPolygon:     " + this.startPolygon.ToString() + " ");
            sb.AppendLine(" SurfaceID :       " + this.surface.ToString() + " ");
            sb.AppendLine(" numberOfPolygons: " + this.numberOfPolygons.ToString() + " ");
            sb.AppendLine(" ==== End of Surface Chunk ======");
            return sb.ToString();
        }

        internal void Save(System.IO.BinaryWriter bw)
        {
            bw.Write(this.startPolygon);//uint startPolygon = br.ReadUInt32();
            bw.Write(this.surface);//uint surface = br.ReadUInt32();
            bw.Write(this.numberOfPolygons);//uint numberOfPolygons = br.ReadUInt32();
            //return new SurfaceChunk(startPolygon, surface, numberOfPolygons);
        }
    }
}
